package com.pms.privilege.func.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pms.privilege.func.dao.FunctionDAO;
import com.pms.privilege.func.model.FunctionModel;
@Service
public class FunctionService {
	@Autowired
	private FunctionDAO dao;
	/**
	 * 分页查询功能列表
	 * @param start
	 * @param end
	 * @return
	 */
	public List<FunctionModel> functionListService(int start,int end){
		List<FunctionModel> list=new ArrayList<FunctionModel>();
		list=dao.queryFunctionList(start, end);
		return list;
		
	}
	/**
	 * 分页查询有效的功能列表
	 * @param start
	 * @param end
	 * @return
	 */
	public List<FunctionModel> functionValidListService(int start,int end){
		List<FunctionModel> list=new ArrayList<FunctionModel>();
		list=dao.queryValidFunctionList(start, end);
		return list;
		
	}
	/**
	 * 新增功能模块
	 * @param fm
	 * @return
	 */
	public int insertFunctionService(FunctionModel fm){
		dao.insertFunction(fm);
		return 0;
		
	}
	/**
	 * 修改功能模块
	 * @param fm
	 * @return
	 */
	public int updateFunctionService(FunctionModel fm){
		dao.updateFunction(fm);
		return 0;
	}
	/**
	 * 删除功能模块
	 * @param func_id
	 * @return
	 */
	public int deleteFunctionService(long func_id){
		dao.deletePermissionByFuncID(func_id);
		dao.deleteFunction(func_id);
		return 0;
	}
}
